

CREATE TABLE [dbo].[Moderation](
	[IdModeration] [bigint] NOT NULL,
	[IdUserCreated] [bigint] NOT NULL,
	[IdUserTarget] [bigint] NOT NULL,
	[Message] [varchar](max) NOT NULL,
	[DateCreated] [datetime2](7) NOT NULL,
	[DateResolved] [datetime2](7) NULL,
	[ResolveMessage] [varchar](max) NULL,
	Context	varchar(128) NULL, 
 CONSTRAINT [PK_Moderation] PRIMARY KEY CLUSTERED 
(
	[IdModeration] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]

GO

ALTER TABLE [dbo].[Moderation] ADD  CONSTRAINT [DF_Moderation_Date]  DEFAULT (getdate()) FOR [DateCreated]
GO

ALTER TABLE [dbo].[Moderation]  WITH CHECK ADD  CONSTRAINT [FK_Moderation_Users_Creation] FOREIGN KEY([IdUserCreated])
REFERENCES [dbo].[Users] ([IdUser])
GO

ALTER TABLE [dbo].[Moderation] CHECK CONSTRAINT [FK_Moderation_Users_Creation]
GO

ALTER TABLE [dbo].[Moderation]  WITH CHECK ADD  CONSTRAINT [FK_Moderation_Users_Target] FOREIGN KEY([IdUserTarget])
REFERENCES [dbo].[Users] ([IdUser])
GO

ALTER TABLE [dbo].[Moderation] CHECK CONSTRAINT [FK_Moderation_Users_Target]
GO


